package com.cw.dubbo.consumer;


import cn.hutool.core.date.DateUtil;
import cn.hutool.core.date.TimeInterval;
import cn.hutool.core.util.RandomUtil;
import com.cw.dubbo.api.LoginService1;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class LoginController {

    @DubboReference
    private LoginService1 loginService;

    @RequestMapping("/")
    public String login(){

        TimeInterval timer = DateUtil.timer();
        timer.start();

        String name = "name" + RandomUtil.randomNumbers(6);
        String pwd = String.valueOf(System.currentTimeMillis());
        String str = loginService.login(name, pwd);

        return "花费: " + timer.interval() + "毫秒, 返回结果: " + str;
    }

}
